package com.example.app;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

public class WifiUtil {
    public static class Holder {
        public static final WifiUtil INSTANCE = new WifiUtil();
    }
    private WifiUtil() {}
    public static WifiUtil getInstance() {
        return Holder.INSTANCE;
    }

    private final String TAG = this.getClass().getSimpleName();
    private Context mContext;
    private WifiManager mWifiManager;

    public void initialize(Context context) {
        mContext = context;
        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    }

    public boolean isWifiEnabled() {
        if (mWifiManager != null) {
            return mWifiManager.isWifiEnabled();
        }
        return false;
    }

    public WifiInfo getConnectionInfo() {
        if (mWifiManager != null) {
            WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
            return wifiInfo;
        }
        return null;
    }
}
